Skip to content

feat(postgres): add destination with automatic schema evolution - #926

Open
riderx wants to merge 3 commits into
supabase:mainfrom
riderx:feat/postgres-destination-auto-schema
Open

feat(postgres): add destination with automatic schema evolution#926
riderx wants to merge 3 commits into
supabase:mainfrom
riderx:feat/postgres-destination-auto-schema

Conversation

@riderx

@riderx riderx commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • Add a Postgres destination that auto-creates destination schemas/tables from the source publication schema.
  • Apply supported schema changes during CDC (add/drop/rename columns, defaults, DROP NOT NULL); reject partial/UnchangedToast updates and handle PK-changing updates via delete-then-upsert.
  • Wire DestinationConfig / replicator / API support, docs, and integration tests for copy, CDC, truncate, schema evolution, and copy reset.

Test plan

  • cargo nextest run -p etl-destinations --features postgres,test-utils -- postgres (8 passed)
  • cargo check -p etl-destinations --features postgres
  • cargo check -p etl-replicator --features postgres
  • cargo check -p etl-api
  • CI green on this PR

Made with Cursor

Add a Postgres destination that auto-creates schemas/tables and applies
supported DDL (add/drop/rename columns, defaults, DROP NOT NULL) during
replication so PG→PG pipelines stay current without manual migrations.

Co-authored-by: Cursor <cursoragent@cursor.com>
@riderx
riderx force-pushed the feat/postgres-destination-auto-schema branch from 282d36f to c353068 Compare July 22, 2026 15:03
@riderx
riderx marked this pull request as ready for review July 22, 2026 15:16
@riderx
riderx requested a review from a team as a code owner July 22, 2026 15:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c353068a5e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/etl-destinations/src/postgres/core.rs
Comment thread crates/etl-api/src/validation/validators/destination.rs
@iambriccardo

Copy link
Copy Markdown
Contributor

Hi, thanks for this PR! We are not accepting new destinations at this moment due to the high workload that the team has, but we are evaluating a Postgres destination in the future.

May I ask for which use case you added this? Did you already try it out in staging/production?

Encode source schema into destination table names when destination_schema
is set, and add API primary-key validation so Postgres publications fail
early instead of at copy time.

Co-authored-by: Cursor <cursoragent@cursor.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@riderx

riderx commented Jul 31, 2026

Copy link
Copy Markdown
Author

@iambriccardo thanks for taking a look, and totally understand the bandwidth constraint.

I'm a paid Supabase Team customer. Today I run custom Postgres replication into Google Cloud because Supabase Pipelines / managed replication doesn't cover my needs:

  • I need partial replication (selected tables / schemas, not the whole DB)
  • I need about 9 geographic locations for customers; managed read replicas are capped lower than that

So I currently use basic Postgres logical replication to those destinations. That works for row data, but schema sync is missing — DDL on the source (add/drop/rename columns, etc.) does not propagate cleanly, which is the gap this PR targets: a Postgres destination with automatic schema creation + evolution on top of ETL's existing CDC/schema pipeline.

I've exercised it locally with the destination integration tests in this PR (initial copy, CDC upsert/delete/truncate, schema add/drop/rename, and copy reset). Not in production yet — happy to keep iterating if/when a Postgres destination is back on the roadmap.

Also addressed the Codex review notes in the latest commit: schema-override table-name collisions and API primary-key validation.

Keep the Postgres destination feature while adopting main's ClickHouse
schema-rewind docs and simplified egress feature wiring.

Co-authored-by: Cursor <cursoragent@cursor.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants